﻿

// index---------------------------------------------------------------------------------------------------
$(function() {

	try {
		$(window)
				.scroll(
						function() {
							var wb = $(this).scrollTop() + $(this).height()
									- 10, wt = $(this).scrollTop();
							$(".progressinvest:not([done='done'])").each(
									function() {
										var _this = $(this)
												.attr("done", "done");
										_this.progressinvest({
											stroke_bg : "#FF4500",
											loop : "#FF4500",
											stroke_width : 15
										});
									});
						}).trigger("scroll");
	} catch (e) {
	}
	

    try {
        $(window).scroll(function () {
            var wb = $(this).scrollTop() + $(this).height() - 10,
            wt = $(this).scrollTop();
            //$(".progress:not([done='done'])").each(function () {
            //    var _this = $(this).attr("done", "done");
            //    _this.progress({stroke_bg: "#DD8403", loop: "#DD8403", stroke_width: 2 });
            //});
        }).trigger("scroll");
    } catch (e) { }
	// 头部
	// 头部
	// 头部
	jQuery(".full_screen_slider").slide(
			{
				titCell : ".hd ul",
				mainCell : ".bd ul",
				effect : "fold",
				autoPlay : true,
				autoPage : true,
				trigger : "click",
				startFun : function(i) {
					var curLi = jQuery(".full_screen_slider .bd li").eq(i);
					if (!!curLi.attr("_src")) {
						curLi.css("background-image", curLi.attr("_src"))
								.removeAttr("_src")
					}
				}
			});



});


// bid------------------------------------------------------------------------------------------------------------

$(function() {
	$("#loanmain li").click(function() {
		var index = $(this).index();
		$(this).addClass("hover").siblings().removeClass("hover");
		$(".loandiv").eq(index).show().siblings(".loandiv").hide();
	});





});
$(function() {
	//通过freemaker获取服务器时间
	var timestamp = parseInt(new Date(Date.parse($('.systime').text())).getTime());
	var fresh_time = function() {
		var d = new Date(timestamp);
		var yyyy = d.getFullYear();
		var MM = d.getMonth() + 1;
		var dd = d.getDate();
		var hh = d.getHours();
		var mm = d.getMinutes();
		var ss = d.getSeconds();
		MM = MM < 10 ? "0" + MM : MM;
		dd = dd < 10 ? "0" + dd : dd;
		hh = hh < 10 ? "0" + hh : hh;
		mm = mm < 10 ? "0" + mm : mm;
		ss = ss < 10 ? "0" + ss : ss;
		$(".systime").html([ yyyy, "-", MM, "-", dd, " ", hh, ":", mm, ":", ss ].join(""));
		timestamp = timestamp + 1000;
	};
	fresh_time();
	setInterval(function() {
		fresh_time();
	}, 1000);
});
$(function() {
	$("input[class*='btn'],a[class*='btn']").hover(function() {
		$(this).stop(true, true).animate({
			"opacity" : 0.5
		});
	}, function() {
		$(this).stop(true, true).animate({
			"opacity" : 1
		});
	});

});
function ajax(options){
	var p = options || {};
	var url = p.url;
	$.ajax({
		cache: false,
		async: p.async == undefined ? true : p.async,
		url: url,
		data: p.data,
		dataType: p.dataType || 'json',
		traditional:true,
		type: p.type || 'POST',
		beforeSend: function () {
			if(options.beforeSend){
				options.beforeSend();
			}
		},
		complete: function () {
			if (options.complete) {
				options.complete();
			}
		},
		success: function (result) {
			if (p.success){
				p.success(result);
			}else{
				oDialog.alert(result.msg);
			}
		},

		error: function (xhr,status) {



			//报错时，不执行complete
			options.loading = false;
			var showError = p.showError || true;

			if(p.error){
				p.error(xhr,status);
			}
			if(xhr.status == 403){
				// window.location = base + "/login.jhtml";
				Login.login().dialogLogin();


			}else if(showError){
				if (options.error) {
					options.error();
				}


				if(xhr.status == 400){
					var responseError = eval(xhr.responseText);
					var info = '';
					for(var i = 0;i < responseError.length;i++){
						info += responseError[i] + '<br/>';
					}
					if(!("undefined" == typeof layer)) {
						layer.alert(info);
					}else{
						oDialog.alert(info, true);
					}
				}else{
					alert('系统出错');
				}
			}


			;
		}
	});
}
/*cookie管理*/
var Cookie = {
	getExpiresDate:function(days, hours, minutes) {
		var ExpiresDate = new Date();
		if (typeof days == "number" && typeof hours == "number" &&
				typeof hours == "number") {
			ExpiresDate.setDate(ExpiresDate.getDate() + parseInt(days));
			ExpiresDate.setHours(ExpiresDate.getHours() + parseInt(hours));
			ExpiresDate.setMinutes(ExpiresDate.getMinutes() + parseInt(minutes));
			return ExpiresDate.toGMTString();
		}
	},
	_getValue:function(offset) {
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1) {
			endstr = document.cookie.length;
		}
		return unescape(document.cookie.substring(offset, endstr));
	},
	get:function(name) {
		var arg = name + "=";
		var alen = arg.length;
		var clen = document.cookie.length;
		var i = 0;
		while (i < clen) {
			var j = i + alen;
			if (document.cookie.substring(i, j) == arg) {
				return this._getValue(j);
			}
			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
		return "";
	},
	set:function(name, value, expires, path, domain, secure) {
		document.cookie = name + "=" + escape (value) +
				((expires) ? "; expires=" + expires : "") +
				((path) ? "; path=" + path : "") +
				((domain) ? "; domain=" + domain : "") +
				((secure) ? "; secure" : "");
	},
	remove:function(name,path,domain) {
		if (this.get(name)) {
			document.cookie = name + "=" +
					((path) ? "; path=" + path : "") +
					((domain) ? "; domain=" + domain : "") +
					"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		}
	},
	clear:function(){
		var cookies = document.cookie.split(';');
		for(var i=0; i < cookies.length; i++)
			var cookieName = cookies[i].split('=')[0];
		if(cookieName=='ProductListIds')
		{
			this.remove(cookieName);
		}
	}
};